﻿using System;
using System.Collections;
using System.Windows.Forms;

namespace HYElectricSystemSetting
{
	public class RowComparer : IComparer
	{
		public RowComparer(SortOrder sortOrder)
		{
			if (sortOrder == SortOrder.Descending)
			{
				RowComparer.sortOrderModifier = -1;
				return;
			}
			if (sortOrder == SortOrder.Ascending)
			{
				RowComparer.sortOrderModifier = 1;
			}
		}

		public int Compare(object x, object y)
		{
			DataGridViewRow dataGridViewRow = (DataGridViewRow)x;
			DataGridViewRow dataGridViewRow2 = (DataGridViewRow)y;
			int num = string.Compare(dataGridViewRow.Cells[1].Value.ToString(), dataGridViewRow2.Cells[1].Value.ToString());
			if (num == 0)
			{
				num = string.Compare(dataGridViewRow.Cells[0].Value.ToString(), dataGridViewRow2.Cells[0].Value.ToString());
			}
			return num * RowComparer.sortOrderModifier;
		}

		private static int sortOrderModifier = 1;
	}
}
